<?=View::factory('admin/common/header')?>
<div id="content">
  <div class="breadcrumb">
    <a href="<?=URL::site('admin')?>">管理首页</a>
    &raquo; <a href="<?=URL::site('admin/article')?>">文章列表</a>
    &raquo; 编辑文章
  </div>
  <?=View::factory('admin/common/message')?>
  <div class="box">
    <div class="heading">
      <h1><img src="<?=URL::site()?>images/admin/layout.png" alt="" /> 编辑文章</h1>
      <div class="buttons">
        <input type="button" onclick="ajax_post();" class="btn45" value="保存" /> &nbsp;
        <input type="button" onclick="history.back();" class="btn45" value="返回" />
      </div>
    </div>
    <div class="content">
      <form method="post" enctype="multipart/form-data" id="form" onsubmit="return ajax_post();">
        <table class="form">
          <tr>
            <td width="120">所属分类</td>
            <td><span class="cats_select"><img src="<?=URL::site()?>images/admin/ajax-loading.gif" align="absbottom" /> <font color="gray">数据加载中…</font></span>
              <font color="gray">所属分类必须是叶子节点</font></td>
          </tr>
          <tr>
            <td>文章标题 <span class="required">*</span></td>
            <td><input type="text" size="80"  maxlength="100" name="title" value="<?=$title?>"/></td>
          </tr>
          <tr>
            <td>显示排序</td>
            <td><input name="sort_order" type="text" size="10" value="<?=$sort_order?>" /></td>
          </tr>
          <tr>
            <td>是否显示</td>
            <td>
            <label><input type="radio" name="is_show" value="1" <?=$is_show?'checked':''?> /> 显示</label> &nbsp;
            <label><input type="radio" name="is_show" value="0" <?=$is_show?'':'checked'?> /> 隐藏</label> &nbsp;
            </td>
          </tr>
          <tr>
            <td valign="top">文章内容 <span class="required">*</span></td>
            <td><?=Editor::factory(NULL, array('name' => 'content', 'value' => $content, 'upload' => TRUE))?></td>
          </tr>
        </table>
      </form>
    </div>
</div>
<?=View::factory('admin/common/footer')?>
<?=HTML::script('admin/article_category/js')?>
<script type="text/javascript">
function ajax_post() {
    $('textarea[name=content]').val(KEditor.html());
    return $('#form').ajax_post({
        redirect :'<?=Helper::factory('redirect')->get(URL::site('admin/article'))?>'
    });
}
$().ready(function(){
    $('.cats_select').html(category_select_reverse(<?=$cat_id?>, 'cat_id'));
    $('#article').addClass('selected');
});
</script>